#include "map/controllers/RouteController.h"
#include "util/events/NewRoadNavigationEvent.h"
#include "util/events/RouteChangeEvent.h"

RouteController::RouteController(QueryRoute* queryRoute) {
	this->queryRoute = queryRoute;
}

RouteController::~RouteController() {

}

RoadNavigation RouteController::getNextAction() {
	return this->queryRoute->nextAction();
}

util::LinkedList<MapPoint>::Iterator RouteController::getRemainingIntersections() {
	return this->queryRoute->getRemainingIntersections();
}

RoadSegment* RouteController::getNextRoadSegment(){
	RoadSegment* ret = this->queryRoute->popSegment();
	RouteChangeEvent routeChangeEvent;
	this->fireEvent(&routeChangeEvent);
	return ret;
}

void RouteController::setNewOrigin(RoadSegment* segment, Intersection* origin){
	this->queryRoute->setOrigin(segment, origin);
	RouteChangeEvent routeChangeEvent;
	this->fireEvent(&routeChangeEvent);
}

void RouteController::setCarController(CarController* carController) {
	this->carController = carController;
}
